﻿Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.Text
Imports System.IO
Imports System.Drawing
Imports System.Web

Public Class ComboGrilla
  Inherits TextBox
  Implements IScriptControl


  Dim ValorValor As String = String.Empty
  Public Property Valor() As String
    Get
      Return ValorValor
    End Get
    Set(ByVal value As String)
      ValorValor = value
    End Set
  End Property
  Dim DescripcionValor As String = String.Empty
  Public Property Descripcion() As String
    Get
      Return DescripcionValor
    End Get
    Set(ByVal value As String)
      DescripcionValor = value
    End Set
  End Property

  Dim DefectoValor As String = String.Empty
  Public Property Defecto() As String
    Get
      Return DefectoValor
    End Get
    Set(ByVal value As String)
      DefectoValor = value
    End Set
  End Property

  Dim CssErrorValor As String = "Erroneo"
  Public Property CssError() As String
    Get
      Return CssErrorValor
    End Get
    Set(ByVal value As String)
      CssErrorValor = value
    End Set
  End Property

  Dim AceptaBlancoValor As Boolean = True
  Public Property AceptaBlanco() As Boolean
    Get
      Return AceptaBlancoValor
    End Get
    Set(ByVal value As Boolean)
      AceptaBlancoValor = value
    End Set
  End Property

 

  'Dim MensajeErrorValor As String = "valor erroneo"
  'Public Property MensajeError() As String
  '  Get
  '    Return MensajeErrorValor
  '  End Get
  '  Set(ByVal value As String)
  '    MensajeErrorValor = value
  '  End Set
  'End Property

  Dim ValidandoValor As String = ""
  Public Property Validando() As String
    Get
      Return ValidandoValor
    End Get
    Set(ByVal value As String)
      ValidandoValor = value
    End Set
  End Property

  Dim GrillaTargetIdValor As String = ""
  Public Property GrillaTargetId() As String
    Get
      Return GrillaTargetIdValor
    End Get
    Set(ByVal value As String)
      GrillaTargetIdValor = value
    End Set
  End Property

  Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
    If Not Me.DesignMode Then
      Dim SM As ScriptManager = ScriptManager.GetCurrent(Page)
      If SM Is Nothing Then
        Throw New HttpException("Debe existir un ScriptManager el la pagina")
      Else
        SM.RegisterScriptControl(Me)
      End If
    End If
    MyBase.OnPreRender(e)
  End Sub
  Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
    If Not Me.DesignMode Then
      ScriptManager.GetCurrent(Me.Page).RegisterScriptDescriptors(Me)
    End If
    MyBase.Render(writer)
  End Sub
  Public Function GetScriptDescriptors() As System.Collections.Generic.IEnumerable(Of System.Web.UI.ScriptDescriptor) Implements System.Web.UI.IScriptControl.GetScriptDescriptors
    Dim descriptor As New ScriptControlDescriptor("MoniMisi2.ComboGrilla", Me.ClientID)
    Dim descriptors As New List(Of ScriptDescriptor)
    descriptor.AddProperty("Defecto", Defecto)
    descriptor.AddProperty("CssError", CssError)
    descriptor.AddProperty("AceptaBlanco", AceptaBlanco)
    'descriptor.AddProperty("MensajeError", MensajeError)
    descriptor.AddProperty("GrillaTargetId", GrillaTargetId)
    descriptor.AddProperty("Descripcion", Descripcion)
    descriptor.AddProperty("Valor", Valor)
    If Me.Validando <> String.Empty Then
      descriptor.AddEvent("Validando", Me.Validando)
    End If
    descriptors.Add(descriptor)
    Return descriptors
  End Function

  Public Function GetScriptReferences() As System.Collections.Generic.IEnumerable(Of System.Web.UI.ScriptReference) Implements System.Web.UI.IScriptControl.GetScriptReferences
    Dim scriptRef As New ScriptReference("MoniMisi2.ComboGrilla.js", Funciones.NombreCompletoEnsamblado(Me.GetType, "MoniMisi2.ComboGrilla"))
    scriptRef.NotifyScriptLoaded = False
    Dim scriptRefs As New List(Of ScriptReference)
    scriptRefs.Add(scriptRef)
    Return scriptRefs
  End Function
End Class
